import {Component, Input, OnInit} from '@angular/core';

@Component({
  selector: 'app-wms-order-table',
  templateUrl: './wms-order-table.component.html',
  styleUrls: ['./wms-order-table.component.css']
})
export class WmsOrderTableComponent implements OnInit {
    testData = {
        title: [],
        data: [{name: 'ceshi', id: '12'}, {name: 'dd', id: '2'}]
    };
    @Input()
    tableData: any;
    // 选中的行
    selectedRowMap = new Map();
    // 判断是否选中
    isSelected = (id) => {
        return this.selectedRowMap.get(id) ? true : false;
    }
    // 处理行选中
    dealSelected = (item) => {
        console.log('点击row');
        if (this.isSelected(item.id)) {
            // 删除此行
            this.selectedRowMap.delete(item.id);
        } else {
            this.selectedRowMap.set(item.id, '1');
        }
    }
    constructor() {
    }

    ngOnInit() {
    }
    delRow ( item, index ) {
        this.tableData.data.splice(index, 1);
    }


}
